﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LosConn.BLL;
using System.Data;

namespace LosConn.Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            String userName = txtUserName.Text;
            String userPassWord = txtUserPassWord.Text;
            BLL.Los_User bll = new Los_User();
            String strWhere = String.Format(" User_Name='{0}' and User_PassWord='{1}' and User_Status=100 ", userName, userPassWord);
            DataTable dt = bll.GetList(strWhere).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                Session["UserName"] = userName;
                Session["UserID"] = dt.Rows[0]["User_ID"].ToString();
                Session["Retail_ID"] = dt.Rows[0]["User_RetailID"].ToString();
                String User_Role_RoleID = dt.Rows[0]["User_Role_RoleID"].ToString();
                String Url = String.Empty;
                switch (User_Role_RoleID)
                {
                    case "1":
                        Url = "/User/UserList.aspx";
                        break;
                    case "2":
                        Url = "/Pay/PayList.aspx";
                        break;
                    case "3":
                        Url = "/PayMoney/PayMoneyRetailList.aspx";
                        break;
                    case "4":
                        Url = "/Data/DataAdd.aspx";
                        break;
                    case "6":
                        Url = "/Data/DataAdd.aspx";
                        break;
                    case "7":
                        Url = "/Order/OrderAdd.aspx";
                        break;
                    case "8":
                        Url = "/Data/DataCheck.aspx";
                        break;
                    case "9":
                        Url = "/Flow/FlowList.aspx";
                        break;
                    case "10":
                        Url = "/User/UserList.aspx";
                        break;
                    default:
                        Url = "/Product/ProductList.aspx";
                        break;
                }
                Response.Redirect(Url);
            }
            else
            {
                Common.JScript.CreatePageScript(this.Page, "login", "alert('用户名或者密码错误，请重新输入！');window.location.href='Login.aspx';", false);
            }
        }
    }
}